package BasicKnowledge;

import java.util.Scanner;

public class Homework {
    public static void main1(String[] args) {
        //求二进制数中 1 的个数问题
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int count = 0;
        while (num != 0) {
            if ((num & 1) != 0) {
                count++;
            }
            num = num >>> 1;
        }
        System.out.println("1的个数为" + count);
    }

    public static void main2(String[] args) {
        //获取一个数二进制序列中所有的偶数位和奇数位， 分别输出二进制序列
        //1.首先1个整数有32个byte位   通过位运算 右移指定的次数  然后&1  就可以得到该位的值
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个整数数字");
        int n = sc.nextInt();

        for (int i = 31; i >= 1; i -= 2) {
            System.out.print("偶数 " + ((n >> i) & 1) + " ");

        }
        System.out.println();
        for (int i = 30; i >= 0; i -= 2) {
            System.out.print("奇数 " + ((n >> i) & 1) + " ");

        }

    }

    public static void main3(String[] args) {
        //模拟登陆
        Scanner sc = new Scanner(System.in);
        int count = 3;
        while (count != 0) {
            System.out.println("请输入密码！");
            String passWord = sc.nextLine();
            if (passWord.equals("123456")) {
                System.out.println("密码输入正确");
                break;
            } else {
                count--;
                System.out.println("密码输入错误！您还有" + count + "次机会！");
            }
        }
    }

    public static String reverseNum(int n) {
        if (n >= 10 ) {
            return n % 10 + reverseNum(n / 10 );
        } else {
            return String.valueOf(n);

        }

    }
    public static void main4 (String[]args){
        //递归反转
        System.out.println("请输入一个整数");
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        System.out.println(reverseNum(num));
    }

    public static void main(String[] args) {
        //n的九九乘法表
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个整数>");
        int n = sc.nextInt();
        for (int i = 1; i <= n ; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print( i + "*" + j + "=" + (i * j) + " ");
            }
            System.out.println();
        }

    }
}
